<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html>
<head>
    <%@include file="../../../resources/inc/head.jsp" %>
    <style>
        .layui-elem-quote {
            padding: 4px 15px;
        }

        .tableBlock {
            margin: 20px auto;
        }

        .tableBlock table {
            width: 100%;
            text-align: center;
            border-collapse: collapse;
            line-height: 36px;
        }

        .tableBlock table th {
            text-align: right;
            padding-right: 12px;
            font-weight: normal;
            color: #1a1a1a;
            white-space: nowrap;
        }

        .tableBlock table td, .tableBlock table th {
            border: 1px solid #e6e6e6;
            font-size: 14px;
        }

        .layui-input, .layui-select, .layui-textarea {
            border: none;
        }

        .upload-div li {
            display: inline-block;
            width: 120px;
            margin-right: 20px;
            vertical-align: top;
            text-align: center;
        }

        .upload-div li .upload-item {
            width: 100%;
            height: 180px;
            text-align: center;
            border: 1px solid #e6e6e6;
            position: relative;
        }

        .layui-input-inline {
            overflow: hidden;
            height: 180px;
            width: 120px
        }

        .layui-upload-drag {
            border: none;
        }
    </style>
</head>

<div class="layui-fluid" style="min-width: 1150px">

    <div class="layui-card">

        <div class="layui-card-body">
            <%--<form class="layui-form" action="">--%>
            <c:if test="${!sessionScope.oauthData.isAuth}">
                <c:if test="${sessionScope.oauthData.status==0}">
                    <a lay-href="<%=basePath%>manager/merchant/certification.html" style="color: red">
                        还未认证，去认证!
                    </a>
                </c:if>
               <%-- <c:if test="${sessionScope.oauthData.status==1}">
                    <a href="javascript:;" style="color: red">
                        认证中...
                    </a>
                </c:if>--%>
                <c:if test="${sessionScope.oauthData.status==3}">
                    <a href="javascript:;" style="color: red">
                        认证失败...
                    </a>
                </c:if>
            </c:if>
             <%--<c:if test="${sessionScope.oauthData.isAuth}">--%>
            <div class="tableBlock">
                <blockquote class="layui-elem-quote">支付配置</blockquote>
                <table id="table">
                    <tbody >
                    <c:forEach items="${merchantPaymentConfigs}" var="config">
                    <tr >
                        <th>APP_ID：</th>
                        <td colspan="5">
                            <p style="width: 200px"  >
                                <input id="appid_${config.id}" name="appid" type="text" value="${config.appId==null?"":config.appId}" placeholder="APP_ID" autocomplete="off" class="layui-input">
                            </p>
                        </td>

                        <th>支付通道：</th>
                        <td>
                            <p style="width: 200px" id="payWay">${config.payWay}</p>
                        </td>
                        <td>
                                <input id='${config.id}' type='button' onclick='update(this)' title=23 value='提交' class="layui-btn layui-btn-normal layui-btn-xs"/>
                        </td>
                    <tr>
                        </c:forEach>
                    </tbody>
                </table>
            </div>

            <script>
                //Demo
                layui.use('form', function () {
                    var form = layui.form;
                    //监听提交
                    form.on('submit(formDemo)', function (data) {
                        layer.msg(JSON.stringify(data.field));
                        return false;
                    });
                });
            </script>
            <%--</c:if>--%>
        </div>
    </div>
</div>

<%@include file="../../../resources/inc/footer.jsp" %>
<script>
    layui.config({
        base: '<%=basePath%>resources/lib/layuiAdmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table', 'laydate'], function () {
        var $ = layui.$
            , form = layui.form
            , table = layui.table;
        var laydate = layui.laydate;
    });

    function update(e) {
        var id = e.id;
       var appid =  $('input#appid_'+id).val()
        var format = /^[A-Za-z0-9]{0,20}$/g;
       if(appid==""){
           layer.msg("APP_ID为空")
           return
       }
        if (!format.test(appid)) {
            layer.msg("APP_ID为20位数字或字母")
            return
        }
        layer.load(2)
        $.ajax({
            url: "<%=basePath%>paymentConfig/update/"+id+".html",
            type: "post",
            data: {appid:appid},
            dataType: "JSON",
            success: function (data) {
                layer.closeAll('loading');
                if (data.success) {
                    layer.msg('提交成功', {
                        offset: '15px'
                        , icon: 1
                        , time: 1000
                    }, function () {
                       location.reload();
                    });
                } else {
                    layer.msg(data.message);
                }
            }
        });
    }
</script>
</body>
</html>

